<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc2" %>
<%@ Register Assembly="IdeaSparx.CoolControls.Web" Namespace="IdeaSparx.CoolControls.Web"
    TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <base target="_self" />
    <title>CoolGridView</title>
    <style type="text/css">
        .GridStyle TR TD, .GridStyle TR TH
        {
            font-family: Tahoma, Verdana, Arial;
            font-size: 10pt;
            padding-left: 4px;
            padding-top: 3px;
            padding-bottom: 3px;
            padding-right: 3px;
            border-top: 1px solid #A5A5A5;
            border-left: 1px solid #A5A5A5;
        }
        .GridStyle TR TH
        {
            background-color: #D3D7ED;
        }
        .GridAlternateRowStyle
        {
            background-color: #E9ECF8;
        }
        .GridRowStyle
        {
            background-color: White;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="margin-left: 30px; margin-top: 30px;">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            Spacer</div>
        <div>
            Spacer<br />
            Spacer<br />
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:MultiView ID="MultiView1" ActiveViewIndex="0" runat="server">
                    <asp:View ID="View1" runat="server">
                        <cc1:CoolGridView ID="CoolGridView1" runat="server" AutoGenerateColumns="False" AllowSorting="True"
                            Height="400px" Width="600px" AllowPaging="false" CssClass="GridStyle" EmptyDataText="No Data to Display">
                            <Columns>
                                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID">
                                    <HeaderStyle Width="120px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">
                                    <HeaderStyle Width="200px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="Tax ID" HeaderText="Tax ID" SortExpression="Tax ID">
                                    <HeaderStyle Width="350px" />
                                </asp:BoundField>
                            </Columns>
                            <BoundaryStyle BorderColor="Gray" BorderWidth="1px" BorderStyle="Solid"></BoundaryStyle>
                            <AlternatingRowStyle CssClass="GridAlternateRowStyle" />
                            <RowStyle CssClass="GridRowStyle" />
                        </cc1:CoolGridView>
                        <br />
                        Click on the button to go to the next view (AJAX)
                        <asp:Button ID="btnNext" runat="server" OnClick="Next" Text="Next"></asp:Button>
                    </asp:View>
                    <asp:View ID="View2" runat="server">
                        <cc1:CoolGridView ID="CoolGridView2" runat="server" AutoGenerateColumns="False" AllowSorting="False"
                            Height="400px" Width="600px" AllowPaging="false" CssClass="GridStyle" EmptyDataText="No Data to Display">
                            <Columns>
                                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID">
                                    <HeaderStyle Width="120px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">
                                    <HeaderStyle Width="200px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="Tax ID" HeaderText="Tax ID" SortExpression="Tax ID">
                                    <HeaderStyle Width="350px" />
                                </asp:BoundField>
                            </Columns>
                            <BoundaryStyle BorderColor="Gray" BorderWidth="1px" BorderStyle="Solid"></BoundaryStyle>
                            <AlternatingRowStyle CssClass="GridAlternateRowStyle" />
                            <RowStyle CssClass="GridRowStyle" />
                        </cc1:CoolGridView>
                        <br />
                        Click on the button to go back (AJAX)
                        <asp:Button ID="btnBack" runat="server" OnClick="Back" Text="back"></asp:Button>
                    </asp:View>
                </asp:MultiView>
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        <asp:Button ID="btnPostBack" runat="server" Text="Do PostBack"></asp:Button>
        <br />
        <table>
            <tr>
                <td>
                    <cc1:CoolGridView ID="CoolGridView3" runat="server" AutoGenerateColumns="False" AllowSorting="False"
                        Height="400px" Width="600px" AllowPaging="true" CssClass="GridStyle" EmptyDataText="No Data to Display"
                        PagerSettings-Mode="NextPreviousFirstLast" PagerSettings-Position="TopAndBottom" PageSize="15">
                        <Columns>
                            <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID">
                                <HeaderStyle Width="120px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">
                                <HeaderStyle Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Tax ID" HeaderText="Tax ID" SortExpression="Tax ID">
                                <HeaderStyle Width="350px" />
                            </asp:BoundField>
                        </Columns>
                        <BoundaryStyle BorderColor="Gray" BorderWidth="1px" BorderStyle="Solid"></BoundaryStyle>
                        <AlternatingRowStyle CssClass="GridAlternateRowStyle" />
                        <RowStyle CssClass="GridRowStyle" />
                    </cc1:CoolGridView>
                </td>
            </tr>
        </table>
        <a href="javascript:TestInModalPopup();">Launch CoolGridView in modal window</a>
    </div>
    </form>

    <script type="text/javascript" language="javascript">
        function TestInModalPopup() {
            window.showModalDialog("Default.aspx", "Modal Window", "dialogWidth:850px; dialogHeight:700px; center:yes");
        }
    </script>

    <!-- 
    This javascript code is required if you are using a CoolGridView inside an update pannel.
    -->

    <script type="text/javascript" language="javascript">
        function AjaxEndRequestHandler(sender, args) {
            var p = sender._updatePanelClientIDs;
            if (p != null)
                for (var j = 0; j < p.length; j++) {
                var scripts = $get(p[j]).getElementsByTagName("script");
                // .text is necessary for IE.
                for (var i = 0; i < scripts.length; i++) {
                    try {
                        eval(scripts[i].innerHTML || scripts[i].text);
                    } catch (e2) { }
                }
            }
        }

        try { Sys.WebForms.PageRequestManager.getInstance().add_endRequest(AjaxEndRequestHandler); }
        catch (e) { alert('sample'); }
    </script>

</body>
</html>
